package cn.peach.pet.domain;

import cn.peach.basic.domain.BaseDomain;
import cn.peach.org.domain.Shop;
import cn.peach.user.domain.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class Pet extends BaseDomain {

    public static final int STATE_ONLINE = 1;
    public static final int STATE_OFFLINE = 0;

    private String name;
    private String resources;
    private BigDecimal saleprice;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date offsaletime;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date onsaletime;
    private Integer state = 0;
    private BigDecimal costprice;
    private Date createtime = new Date();
    private Long type_id;
    private PetType type;
    private Long shop_id;
    private Shop shop;
    private Long user_id;
    private User user;
    private Long search_master_msg_id;
    private Integer store_number;

    private PetDetail detail = new PetDetail();

    public String getPic(){
        if (StringUtils.isEmpty(resources)){
            return resources.split(",")[0];
        }
        return "";
    }
}
